package gamemode.gamemode;

import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.ai.attributes.Attribute;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.ForgeMod;
import net.minecraftforge.event.TickEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class Main {
    @SubscribeEvent
    public static void onHandler(TickEvent.PlayerTickEvent event){
        //if(event.player instanceof Player player){
        Player player=event.player;
            if(player.isCreative()){
                player.setInvulnerable(false);
                player.getAttributes().getInstance(Attributes.MAX_HEALTH).setBaseValue(20);
                player.getAbilities().invulnerable=false;
                player.getAbilities().instabuild=false;
                player.invulnerable=false;
                player.getAbilities().mayfly=false;
                player.getAbilities().flying=false;

                /*player.getAttribute(ForgeMod.ATTACK_RANGE.get()).setBaseValue(100);
                player.getAttribute(ForgeMod.REACH_DISTANCE.get()).setBaseValue(100);*/
            }
        //}
    }
}
